<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="com.sinba.common.business.service.IMatchService"%>
<%@page import="com.sinba.common.business.dto.MatchQueryDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%

if(session.getAttribute("password2")==null){
	/* response.sendRedirect( "login2.jsp?pageUrl=user/matchSell.jsp?status="+request.getParameter("status"));
	return; */
}

MatchQueryDTO queryDTO = new MatchQueryDTO();
queryDTO.setSellUser((String)session.getAttribute("loginName"));
int pages = 1;
if(request.getParameter("pages")!=null && request.getParameter("_pages")!=""){
	pages = Integer.parseInt(request.getParameter("pages"));
}
String status = request.getParameter("status");
if(status != null && status.matches("\\d+")){
	if("1".equals(status)){
		queryDTO.setMatchStates(new Integer[]{1,3});
		//queryDTO.setStatus( Integer.parseInt(status) );
	}
	request.setAttribute("pageUrl","matchSell.jsp?status="+ queryDTO.getStatus());
}else{
	request.setAttribute("pageUrl","matchSell.jsp?status=0");status = "0";
}
request.setAttribute("status",status);
int rows = 10;
int start = ( pages - 1 ) * rows;
queryDTO.setStart( start );
queryDTO.setLimit( rows );
ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
IMatchService matchService = (IMatchService)ac.getBean("matchService");
PageDTO dto = matchService.findMatchPage(queryDTO, "desc", "createTime");
dto.setPage(pages); dto.setRows(rows);
request.setAttribute("pageDto",dto);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
	<c:if test="${status eq '0'}"><fmt:message key="i18n.transfer.acceptList"/> </c:if>
	<c:if test="${status eq '1'}"><fmt:message key="i18n.transfer.confirmList"/> </c:if>
</title>
<link rel="shortcut icon" href="../index/favicon.png" />
<link href="../skin/skin1/css/subPage.css" rel="stylesheet">
<link rel="stylesheet" href="css/sub_page_main_style.css" />

<script type="text/javascript" src="../scripts/jquery/jquery-1.4.2.min.js"></script>
</head>
<body style="background:#ede3d1;">
<div class="account">
	<div class="top"><fmt:message key="i18n.tradeMg"/> &gt; 
	<c:if test="${status eq '0'}"><fmt:message key="i18n.transfer.acceptList"/> </c:if>
	<c:if test="${status eq '1'}"><fmt:message key="i18n.confirmList"/> </c:if>
	 </div>
	<!-- <div class="left"></div> -->
    <div class="right" >
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    	<c:if test="${status eq '0'}"><!-- 需收款列表 -->
    	<tr>
    		<%-- <th><fmt:message key="i18n.xuhao"/></th>  --%>
    		<th><fmt:message key="i18n.transfer.matchDate"/></th> 
    		<th><fmt:message key="i18n.transfer.status"/> </th> 
    		<th><fmt:message key="i18n.transfer.date"/></th>
    		<th><fmt:message key="i18n.SenderStatus" /></th>
    		<th><fmt:message key="i18n.transfer.user"/> </th> 
    		<th><fmt:message key="i18n.senderName"/> </th>
    		<th><fmt:message key="i18n.transfer.userPhone"/> </th>
    		<th><fmt:message key="i18n.remittanceMoney"/></th>
    		<th><fmt:message key="i18n.invesmentMoney"/></th>
    		<th>确认收款时间</th>
		</tr>
        <c:if test="${pageDto.totalSize eq 0}">
		<tr><td colspan="14" align="center"><fmt:message key="i18n.noData"/></td></tr>
		</c:if>	
		<c:if test="${pageDto.totalSize ne 0}">
			<c:forEach items="${pageDto.data}" var="data">
			<tr>
				<%-- <td>${data.id }</td> --%>
				<td><fmt:formatDate value="${data.createTime}" pattern="yyyy-MM-dd"/> </td>
				<td><%-- ${data.status } --%>
					<c:if test="${data.status == 0}"><span style="color:red;"><fmt:message key="i18n.Matched"/> </span></c:if>
					<c:if test="${data.status == 1}"><span style="color:blue;"><fmt:message key="i18n.Remitted"/> </span></c:if>
					<c:if test="${data.status == 2}"><span style="color:green;"><fmt:message key="i18n.tranSuccess"/> </span></c:if>
					<c:if test="${data.status == 3}"><span style="color:#EC2085;"><fmt:message key="i18n.stautsNotReceive"/></span></c:if>
					<c:if test="${data.status == 4}"><fmt:message key="i18n.remittancesTimeout"/></c:if>
					<c:if test="${data.status == 5}"><fmt:message key="i18n.verifyTimeout"/></c:if>
					<c:if test="${data.status == 6}"><fmt:message key="i18n.cleaned"/></c:if>
				</td>
				<td><fmt:formatDate value="${data.messageTime}" pattern="yyyy-MM-dd"/></td>
				<td><%--<!-- 汇款人状态 --> --%>
					<c:if test="${data.buyUserStatus == null || data.buyUserStatus == 0 }">
						<span style="color: green;"><fmt:message key="i18n.zhengc"/></span>
					</c:if>
					<c:if test="${data.buyUserStatus == 1 }">
						<span style="color: red;"><fmt:message key="i18n.freeze"/>(立即通过站内通讯联系管理员)</span>
					</c:if>
				</td>
				<td>${data.buyUser }</td>
				<td>${data.buyUserName }</td>
				<%-- <td>${data.buyUserBankQq }</td> --%>
				<td>${data.buyUserBankPhone }</td>
				<td>${data.matchMoney }</td>
				<td>${data.sellMoney }</td>
				<td>
					<fmt:formatDate value="${data.closeTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
					<c:if test="${not empty data.confirmType}">(${data.confirmType})</c:if>
				</td>
			</tr>
			</c:forEach>
		</c:if>
		</c:if>
		<c:if test="${status eq '1'}"><!-- 需确认列表 -->
    	<tr>
    		<th><fmt:message key="i18n.xuhao"/></th> <th><fmt:message key="i18n.transfer.date"/></th>
    		<th><fmt:message key="i18n.transfer.acceptUser"/></th> <th><fmt:message key="i18n.transfer.user"/></th>
			<th><fmt:message key="i18n.senderName"/></th> <!-- <th>汇款人QQ</th> -->
			<th><fmt:message key="i18n.transfer.userPhone"/> </th> 
			<th><fmt:message key="i18n.SenderStatus"/></th>
    		<th><fmt:message key="i18n.ProcessingStatus"/></th> 
    		<th><fmt:message key="i18n.remittanceMoney"/></th>
    		<th><fmt:message key="i18n.MessageContent"/></th>
    		<!-- <th>回复内容</th> 
    		<th>回复日期</th> 
    		<th><fmt:message key="i18n.CredentialImage"/></th> -->
    		<th><fmt:message key="i18n.operation"/></th>
		</tr>
        <c:if test="${pageDto.totalSize eq 0}">
		<tr><td colspan="14" align="center"><fmt:message key="i18n.noData"/></td></tr>
		</c:if>	
		<c:if test="${pageDto.totalSize ne 0}">
			<c:forEach items="${pageDto.data}" var="data">
			<tr>
				<td>${data.id }</td>
				<td><fmt:formatDate value="${data.messageTime}" pattern="yyyy-MM-dd"/></td>
				<td>${data.sellUser }</td> 
				<td>${data.buyUser }</td> 
				<td>${data.buyUserName }</td>
    			<%-- <td>${data.buyUserBankQq }</td>  --%>
    			<td>${data.buyUserBankPhone }</td>
	    		<td>
	    			<c:if test="${data.buyUserStatus == null || data.buyUserStatus == 0 }">
						<span style="color: green;"><fmt:message key="i18n.zhengc"/></span>
					</c:if>
					<c:if test="${data.buyUserStatus == 1 }">
						<span style="color: red;"><fmt:message key="i18n.freeze"/>(立即通过站内通讯联系管理员)</span>
					</c:if>
	    		</td>
	    		<td style="color:red;"><fmt:message key="i18n.Pending"/></td>
				<td>${data.matchMoney}</td>
				<td>${data.message}</td>
	    		<!-- <td>回复内容</td>
	    		<td>回复日期</td> -->
	    		<%-- <td><fmt:message key="i18n.CredentialImage"/></td> --%>
	    		<td>
	    			<a class="optionTagA" href="sureGetPay.jsp?id=${data.id}">[<fmt:message key="i18n.ConfirmPayment"/>]</a>
	    			<c:if test="${data.status eq 1}">
	    				<a class="optionTagA" href="javascript:notReceive('${data.id }')">[<fmt:message key="i18n.stautsNotReceive"/>]</a>
	    			</c:if>
	    		</td>
			</tr>
			</c:forEach>
		</c:if>
		</c:if>
    	</table>
    	<!-- 分页 start -->
		<div class="page">
		<div id="tr_recommendGrid_pager" class="page_r">
			<ul>
				<li><a href="${pageUrl }&pages=1"><fmt:message key="i18n.firstPage"/></a></li>
				<c:if test="${pageDto.page > 1}">
					<li><a href="${pageUrl }&pages=${transferPageDTO.page-1}"><fmt:message key="i18n.upPage"/></a></li>
				</c:if>
				<li><a>${pageDto.page}/${pageDto.total}</a></li>
				<c:if test="${pageDto.page+1<=pageDto.total}">
					<li><a href="${pageUrl }&pages=${pageDto.page+1}"><fmt:message key="i18n.nextPage"/></a></li>
				</c:if>
				<li><a href="${pageUrl }&pages=${pageDto.total}"><fmt:message key="i18n.endPage"/></a></li>
				<li><a><fmt:message key="i18n.total"/>${pageDto.totalSize}<fmt:message key="i18n.tiao"/></a></li>
			</ul>
		</div>
		</div>
		<!-- 分页 end  -->
		<form action="match!notReceive.action" id="confirmPay_form" method="post">
			<input type="hidden" name="pageUrl" value="matchSell.jsp?status=1" />
			<input type="hidden" name="matchId" id="matchId"  />
		</form>
    </div>
</div>

<script>
function notReceive(id){
	$('#matchId').val(id);
	if(confirm('确认未收到款项？')){
		$('#confirmPay_form').submit();
	}
}

</script>

</body>
</html>